version: '2.1'

networks:
    extnetwork:
      ipam:
         config:
         - subnet: 192.168.0.0/24
           gateway: 192.168.0.1

services:
    monitor:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        depends_on:
            - consul
            - prometheus
            - grafana
        networks:
            extnetwork:

    servers:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        depends_on:
            - master1
            - master2
            - master3
            - metanode1
            - metanode2
            - metanode3
            - metanode4
            - datanode1
            - datanode2
            - datanode3
            - datanode4
        networks:
            extnetwork:

    master1:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "5901"
            - "5902"
            - "17010"
            - "17020"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/master1/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/master1/log:/cfs/log
            - ./conf/master1.json:/cfs/conf/master.json
            - ./script/start_master.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.11

    master2:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "5901"
            - "5902"
            - "17010"
            - "17020"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/master2/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/master2/log:/cfs/log
            - ./conf/master2.json:/cfs/conf/master.json
            - ./script/start_master.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.12
    master3:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "5901"
            - "5902"
            - "17010"
            - "17020"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/master3/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/master3/log:/cfs/log
            - ./conf/master3.json:/cfs/conf/master.json
            - ./script/start_master.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.13

    metanode1:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17210"
            - "17220"
            - "17230"
            - "17240"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/metanode1/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/metanode1/log:/cfs/log
            - ./conf/metanode.json:/cfs/conf/metanode.json
            - ./script/start_meta.sh:/cfs/script/start.sh
        command: /bin/bash /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.21

    metanode2:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17210"
            - "17220"
            - "17230"
            - "17240"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/metanode2/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/metanode2/log:/cfs/log
            - ./conf/metanode.json:/cfs/conf/metanode.json
            - ./script/start_meta.sh:/cfs/script/start.sh
        command: /bin/bash /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.22

    metanode3:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17210"
            - "17220"
            - "17230"
            - "17240"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/metanode3/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/metanode3/log:/cfs/log
            - ./conf/metanode.json:/cfs/conf/metanode.json
            - ./script/start_meta.sh:/cfs/script/start.sh
        command: /bin/bash /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.23

    metanode4:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17210"
            - "17220"
            - "17230"
            - "17240"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/metanode4/data:/cfs/data
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/metanode4/log:/cfs/log
            - ./conf/metanode.json:/cfs/conf/metanode.json
            - ./script/start_meta.sh:/cfs/script/start.sh
        command: /bin/bash /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.24

    datanode1:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17310"
            - "17320"
            - "17330"
            - "17340"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/datanode1/disk:/cfs/disk
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/datanode1/log:/cfs/log
            - ./conf/datanode.json:/cfs/conf/datanode.json
            - ./script/start_datanode.sh:/cfs/script/start.sh
        command: /bin/bash /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.31

    datanode2:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17310"
            - "17320"
            - "17330"
            - "17340"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/datanode2/disk:/cfs/disk
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/datanode2/log:/cfs/log
            - ./conf/datanode.json:/cfs/conf/datanode.json
            - ./script/start_datanode.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.32

    datanode3:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17310"
            - "17320"
            - "17330"
            - "17340"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/datanode3/disk:/cfs/disk
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/datanode3/log:/cfs/log
            - ./conf/datanode.json:/cfs/conf/datanode.json
            - ./script/start_datanode.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.33

    datanode4:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "17310"
            - "17320"
            - "17330"
            - "17340"
            - 9500
        volumes:
            - ${DiskPath:-./docker_data}/datanode4/disk:/cfs/disk
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/datanode4/log:/cfs/log
            - ./conf/datanode.json:/cfs/conf/datanode.json
            - ./script/start_datanode.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.34

    objectnode1:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "80"
            - 9500
        volumes:
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/objectnode1/log:/cfs/log
            - ./conf/objectnode.json:/cfs/conf/objectnode.json
            - ./script/start_objectnode.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        environment:
          - TZ=Asia/Shanghai
        networks:
            extnetwork:
                ipv4_address: 192.168.0.41

    objectnode2:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "80"
            - 9500
        volumes:
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/objectnode2/log:/cfs/log
            - ./conf/objectnode.json:/cfs/conf/objectnode.json
            - ./script/start_objectnode.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        environment:
          - TZ=Asia/Shanghai
        networks:
            extnetwork:
                ipv4_address: 192.168.0.42

    objectnode3:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - "80"
            - 9500
        volumes:
            - ./bin:/cfs/bin:ro
            - ${DiskPath:-./docker_data}/objectnode3/log:/cfs/log
            - ./conf/objectnode.json:/cfs/conf/objectnode.json
            - ./script/start_objectnode.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        environment:
          - TZ=Asia/Shanghai
        networks:
            extnetwork:
                ipv4_address: 192.168.0.43


    console1:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
          - "80"
        volumes:
          - ./bin:/cfs/bin:ro
          - ${DiskPath:-./docker_data}/console/log:/cfs/log
          - ./conf/console.json:/cfs/conf/console.json
          - ./script/start_console.sh:/cfs/script/start.sh
        command: /bin/sh /cfs/script/start.sh
        restart: on-failure
        privileged: true
        networks:
          extnetwork:
            ipv4_address: 192.168.0.50

    client:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        ports:
            - 9500
            - 17410:17410
        volumes:
            - ./bin:/cfs/bin:ro
            - ./conf/hosts:/etc/hosts:ro
            - ./conf/client.json:/cfs/conf/client.json
            - ${DiskPath:-./docker_data}/client/log:/cfs/log
            - ./script/run_test.sh:/cfs/script/start.sh
            - ./script/start_client.sh:/cfs/script/start_client.sh
            - ./ltp/runtest/fs:/opt/ltp/runtest/fs
            - ./s3tests:/opt/s3tests:ro
        privileged: true
        devices:
            - /dev/fuse:/dev/fuse:rwm
        cap_add:
            - SYS_ADMIN
        command: /bin/bash /cfs/script/start.sh
        networks:
            extnetwork:

    consul:
        image: consul:1.5
        ports:
            - 8500:8500
        volumes:
            - ./monitor:/monitor
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.101

    prometheus:
        image: prom/prometheus
        ports:
            - 9090:9090
        volumes:
            - ./monitor/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.102

    grafana:
        image: grafana/grafana:6.4.4
        environment:
            - GF_SECURITY_ADMIN_PASSWORD=123456
        ports:
            - 3000:3000
        volumes:
            - ./monitor/grafana/grafana.ini:/etc/grafana/grafna.ini
            - ./monitor/grafana/provisioning:/etc/grafana/provisioning
            - ./monitor/grafana/init.sh:/grafana/init.sh
        privileged: true
        #command: /bin/bash
        networks:
            extnetwork:
                ipv4_address: 192.168.0.103

    nginx:
        image: nginx:1.17.8
        ports:
            - "80:80"
        volumes:
            - ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
        command: /bin/bash -c "nginx -g 'daemon off;'"
        restart: on-failure
        privileged: true
        networks:
            extnetwork:
                ipv4_address: 192.168.0.104

    build:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        volumes:
            - ../:/go/src/github.com/cubefs/cubefs
        command:
            /bin/bash /go/src/github.com/cubefs/cubefs/docker/script/build.sh
        networks:
            extnetwork:

    unit_test:
        image: ghcr.dockerproxy.com/cubefs/cbfs-base:1.0-golang-1.16.12
        volumes:
            - ../:/go/src/github.com/cubefs/cubefs
        command:
            - bash
            - "-c"
            - >-
                set -e;
                mkdir -p /go/src/github.com/cubefs/cubefs/docker/bin &&
                cd /go/src/github.com/cubefs/cubefs && make testcover
        networks:
            extnetwork:
